package com.yl.common.utils

import org.springframework.beans.BeansException
import org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationContextAware
import org.springframework.core.annotation.Order
import org.springframework.stereotype.Component

@Component("applicationContextUtil")
class ApplicationContextUtil: ApplicationContextAware {
	companion object {
		private lateinit var applicationContext:ApplicationContext

		fun getApplicationContext(): ApplicationContext {
			return applicationContext
		}

		@Throws(BeansException::class)
		fun getBean(name: String): Any {
			return applicationContext.getBean(name)
		}
	}

	override fun setApplicationContext(applicationContext: ApplicationContext) {
			ApplicationContextUtil.applicationContext = applicationContext

	}
}
